package shun.demo.memory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chen on 12/19/13.
 */
public class MemoryUtil {

    public static void allocateFixedMB() {
        allocateMB(180);
    }

    public static void allocateMB(int mb) {
        for (int i = 0; i < mb; i++) {
            allocate1MB();
        }
    }

    private static void allocate1MB() {
        for (int i = 0; i < 256; i++) {
            allocate4KB();
        }
    }

    private static void allocate4KB() {
        memory.add(new byte[1024 * 4]);
    }

    private static List<byte[]> memory = new ArrayList<byte[]>();


}
